"use strict";

const Controller = require("egg").Controller;

class MiniController extends Controller {
  constructor(ctx) {
    super(ctx);
    this.platform = ctx.request.body.platform;
    if (this.platform === "wemini") this.service = ctx.service.wemini;
    if (this.platform === "douyin") this.service = ctx.service.douyin;
  }

  async upload() {
    this.ctx.body = await this.service.upload(this.ctx.request.body);
    this.service.end();
    this.ctx.status = 201;
  }
  async preview() {
    this.ctx.body = await this.service.preview(this.ctx.request.body);
    this.service.end();
    this.ctx.status = 201;
  }
  async sourceMap() {
    this.ctx.body = await this.service.sourceMap(this.ctx.request.body);
    this.service.end();
    this.ctx.status = 201;
  }
}
module.exports = MiniController;
